﻿<Page
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
      xmlns:commandModel="clr-namespace:FitnessTrackerUI.Command" 
      xmlns:viewModel="clr-namespace:FitnessTrackerUI.ViewModel"
      x:Class="FitnessTrackerUI.View.ConnectHxMPage"
      mc:Ignorable="d" d:DesignWidth="447.253"
	  Title="ConnectHxMReaderPage"
      WindowTitle="Running With Windows - Connect to HxMReader">
    <Page.Resources>
        <viewModel:ConnectToHxMViewModel x:Key="PropertiesViewModel"/>
        <commandModel:ConnectHxMCommands x:Key="CommandsViewModel"/>
    </Page.Resources>
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition/>
            <ColumnDefinition/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition/>
            <RowDefinition/>
        </Grid.RowDefinitions>
        <Button Command="{Binding Path = ConnectToHxMCommand}" 
                CommandParameter="{StaticResource PropertiesViewModel}" 
                Content="Connect HxMReader" 
                Margin="30,60,30,30"
                IsEnabled="{Binding Source={StaticResource PropertiesViewModel}, Path=IsReconnectionApplicable}">
                <Button.DataContext>
                    <Binding Source="{StaticResource CommandsViewModel}"/>
                </Button.DataContext>
        </Button>
        <TextBlock HorizontalAlignment="Left" 
                   Margin="20,0,0,20"
                   TextWrapping="Wrap"
                   VerticalAlignment="Bottom"
                   Grid.Row="2" 
                   FontSize="14">
            <Hyperlink NavigateUri="HomePage.xaml">
                <Run Text="Home"/>
            </Hyperlink>
        </TextBlock>
        <TextBlock HorizontalAlignment="Right"
                   Margin="0,0,20,20"
                   TextWrapping="Wrap"
                   VerticalAlignment="Bottom"
                   Grid.Row="1"
                   FontSize="14"
                   Grid.Column="1">
            <Hyperlink NavigateUri="WorkoutPage.xaml" IsEnabled="{Binding IsConnectionToHxMValidated}">
                <Run Text="New Workout"/>
                <Hyperlink.DataContext>
                    <Binding Source="{StaticResource PropertiesViewModel}"/>
                </Hyperlink.DataContext>
            </Hyperlink>
        </TextBlock>
        <TextBox Text="{Binding StatusMessage}"
                 Grid.Column="1"
                 Margin="30,60,30,30" 
                 TextWrapping="Wrap" 
                 MinLines="5"
                 VerticalScrollBarVisibility="Auto"
                 IsReadOnly="True"
                 Grid.Row="0" >
            <TextBox.DataContext>
                <Binding Source="{StaticResource PropertiesViewModel}"/>
            </TextBox.DataContext>
        </TextBox>
        <Label Content="Conection Progress"
               Grid.Column="1" 
               HorizontalAlignment="Left" 
               Margin="30,30,0,0"
               VerticalAlignment="Top"/>
        <Label x:Name="LblComPortNumber" Content="COM Port"
               HorizontalAlignment="Left"
               Margin="30,30,0,0"
               VerticalAlignment="Top"/>
        <TextBox HorizontalAlignment="Left"
                 Margin="98,35,0,0"
                 TextWrapping="Wrap"
                 Text="{Binding Source={StaticResource PropertiesViewModel},
                        Path=SerialPortName,
                        Mode=TwoWay,
                        UpdateSourceTrigger=PropertyChanged}"
                 VerticalAlignment="Top"
                 Height="{Binding Height, ElementName=LblComPortNumber}" BorderThickness="2">
        </TextBox>
    </Grid>
</Page>
